

import 'package:flutter/material.dart';
import 'package:flutter_application_1/pages/home/home_page.dart';
import 'package:flutter_application_1/pages/web_view_page.dart';

class Routes {
  static Route<dynamic> generateRoute(RouteSettings settings) {
    switch (settings.name) {
      case RouterPath.home:
        return pageRoute(const HomePage(), settings: settings);
      case RouterPath.webview:
        return pageRoute(const WebViewPage(title: "webview"), settings: settings);
      default:
        return MaterialPageRoute(
          builder: (context) => const Scaffold(
            body: SafeArea(
              child: Center(child: Text("No found")),
            ),
          ),
        );
    }
  }

  static MaterialPageRoute pageRoute(Widget page, {RouteSettings? settings, bool? fullscreenDialog, bool? maintainState, bool? allowSnapshotting}) {
    return MaterialPageRoute(builder: (context) => page, 
    settings: settings,
    fullscreenDialog: fullscreenDialog ?? false,
    maintainState: maintainState ?? true,
    allowSnapshotting: allowSnapshotting ?? true,
    );
  }
}

class RouterPath {
  static const String home = '/';
  static const String webview = '/webview_page';
} 